package Demo1;

import java.util.Scanner;

public class Main13 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int ret = 0;
            int y = in.nextInt();
            int o = in.nextInt();
            int u = in.nextInt();
            // 判断you
            int m = Math.min(Math.min(y,o),u);
            ret += m * 2;
            y -= m;
            o -= m;
            u -= m;
            // 判断oo
            if(o > 1) ret+= o;
            System.out.println(ret);
        }
    }
}